//
//  SWCommonMacro.h
//  SWCommonFrame
//
//  Created by shaowei on 13-4-26.
//  Copyright (c) 2013年 shaowei. All rights reserved.
//


#ifndef SWCommonFrame_SWCommonMacro_h
#define SWCommonFrame_SWCommonMacro_h

#import "Dlog.h"

//设备判断
#define INTERFACE_IS_PAD     ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
#define INTERFACE_IS_PHONE   ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)

//设备尺寸
#define SCREEN_WIDTH  ([[UIScreen mainScreen] bounds].size.width) //屏幕宽度
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height) //屏幕高度
#define SCREEN_HEIGHT_NOSTATUS ([[UIScreen mainScreen] bounds].size.height-20) //屏幕高度,去掉状态栏

//加载View-xib
#define VIEW_WITH_XIBNAME(viewName) [[[NSBundle mainBundle] loadNibNamed:XIBNAME_LOAD(viewName) owner:nil options:nil] lastObject]

#define VIEW_WITH_XIBNAME_AND_OWNER(viewName,ownerObj) [[[NSBundle mainBundle] loadNibNamed:XIBNAME_LOAD(viewName) owner:ownerObj options:nil] lastObject]

#define ARRAY_WITH_NAME(fileName,extName) [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:fileName ofType:extName]]

//View动画过渡统一时间
#define VIEW_ANIMATION_DURATION 0.3f 

//获取系统版本号
#define OS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]


//系统目前的语言
#define CurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])

//判断iPhone 是否高清，判断是否是iPhone5
#define iPhoneIsRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
#define IsiPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

//判断ARC
//#if __has_feature(objc_arc)
////compiling with ARC
//#else
//// compiling without ARC
//#endif

//安全的release，（便于以后arc的转换）
#define RELEASE_SAFELY(__POINTER) { [__POINTER release]; __POINTER = nil; }

//弧度与角度的转换
#define DegreesToRadian(x) (M_PI * (x) / 180.0)
#define RadianToDegrees(radian) (radian*180.0)/(M_PI)

//颜色的快速输入
#define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
#define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]

//rgb颜色转换（16进制->10进制）
#define UIColorFromHexadecimal(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

#define LocalizedString(string)  NSLocalizedString(string, nil)

//自定义的断言格式
#define SWASSERT(bool,fmt, ...) NSAssert4(bool, @"%s-%d-%s:%@",__FILE__,__LINE__,__func__,SWString(fmt,##__VA_ARGS__))
#define SWASSERT_SWITCH_OVER SWASSERT(0,@"Switch超出界限")

//简化NSString 的创建方式
#define SWString(fmt, ...) [NSString stringWithFormat:fmt,##__VA_ARGS__]

//判断CGFloat 值是否等于0
#define CGFLOAT_EQUAL_ZERO(value) fabsf(value - 0.0f) < 0.01f









#endif
